Data processor

ABSTRACT

The RISC data processor is based on the idea that in case that there are many flag-generating instructions, the number of flags generated by each instruction is increased so that a decrease of flag-generating instructions exceeds an increase of flag-using instructions in quantity, thereby achieving the decrease in instructions. With the data processor, an instruction for generating flags according to operands&#39; data sizes is defined. To an instruction set handled by the RISC data processor, an instruction capable of executing an operation on operand in more than one data size, which performs a process identical to an operation process conducted on the small-size operand on low-order bits of the large-size operand, and generates flags capable of coping with the respective data sizes regardless of the data size of each operand subjected to the operation is added. Thus, the reduction in instruction code space of the RISC data processor tight in instruction code space can be achieved.

CLAIM OF PRIORITY

The Present application claims priority from Japanese application JP2008-037069 filed on Feb. 19, 2008, the content of which is herebyincorporated by reference into this application.

FIELD OF THE INVENTION

The present invention relates to a data processor such as amicroprocessor and a microcomputer, and particularly to a techniquewhich enables an efficient code assignment for an instruction.

BACKGROUND OF THE INVENTION

With microprocessors, 32-bit processors had been in the mainstream for along time after development of a 68020 microprocessor by Motorola, Inc.in 1984. This is because 2³² B=4 GB, which can be designated with 32bits, had been a sufficiently large address space over about twentyyears. However, in recent years 64-bit processors, which make possibleto handle a space over 4 GB, have been becoming popular in the field ofPCs and servers owing to the increase in required memory capacity withthe enhancement of system performance and the drop in the unit price ofmemories. Incidentally, it is noted that PC is an abbreviation for“personal computer”. Also, it is forecasted that embedded processorswill shift to 64 bits several to ten years later as if they follow theclimate of the field of PCs and servers.

Unlike processors for PCs and servers, which are required to put toppriority on performance, embedded processors are required to achieveboth high efficiency and high performance. Consequently, embeddedprocessors of RISC (Reduced Instruction Set Computer) type which canachieve high code efficiencies and handle instruction sets with a fixedlength of 16 bits have become widespread. High code efficiencies arevital to make effective use of on-chip caches, RAMs and ROMs even in thecurrent situation that larger capacities of off-chip memories have beenachieved. However, in order to arrange such processors so as to support64 bits, it is essential to efficiently use an instruction code spacewith a fixed length of 16 bits.

The 32-bit processors' age continued for a long time. In Consequence,the basis of operations has been shifted to 32 bits, and it has becomecommon practice to extend 8- or 16-bit data to 32 bits on a register ofa processor before handling, or to deal with data in sets of four 8-bitdata or two 16-bit data, i.e. in 32 bits. Also, 64-bit processors arerequired to support an operational system based on 32 bits like this inaddition to a 64-bit operational system. On this account, with regard toexisting 64-bit processors, both 32-bit and 64-bit operationinstructions are defined for the same operation as required. Inconsequence, the number of operation instructions rises as to 64-bitprocessors, and code spaces required for defining the operationinstructions also increase.

SUMMARY OF THE INVENTION

As described above, to arrange an embedded processor of RISC typedesigned for an instruction code with a fixed length of 16 bits so as tocope with 64 bits, it is essential to make effective use of a code spacefor instructions, which is also referred to as “instruction code space”simply. Especially, 64-bit processors are required to support both32-bit and 64-bit operational systems unlike 32-bit processors whichsupport only 32-bit operational systems suffice, but sufficenevertheless. In case that 32-bit and 64-bit operation instructions areboth defined for one operation as performed for existing 64-bitprocessors for meeting such requirement, an instruction set with a fixedlength of 16 bits uses a considerable or excessively large part of theinstruction code space, and therefore it becomes difficult to build up a64-bit operational system comparable to an existing 32-bit operationalsystem. For example, under the condition that there are 256 kinds ofoperation codes for instructions of an instruction set with a 32-bitoperational system, which can be expressed with eight bits, when anattempt to add 64-bit operation instructions is made simply, it becomesnecessary to increase the number of bits of the operation codes by atleast one bit. As a result, the instruction code space is enlarged, andit becomes impossible to keep an existing instruction system for 32-bitoperations.

Particularly, in the condition that the low-order 32 bits of a result ofa 64-bit operation are the same as those of a 32-bit operation, if theflag generated from the result of the operation varies between 32-bitand 64-bit operations, it is required to define a different instruction.If only the generated flag changes, the number of instructions whichgenerate a flag can be reduced by increasing the number of flagsgenerated by each instruction. For example, more than one type of flags,such as Positive, Negative, Zero, Overflow and Carry, are generated withone instruction in a Power PC described in the document, “PowerPC UserInstruction Set Architecture Book I Version 2.02”, presented at thefollowing Internet URL hit in search as of Jan. 23, 2008:

<http://www.ibm.com/developerworks/power/library/pa-archguidev2>.In addition, in the case of JP-A-6-337783, more than one type of flagsfor more than one size is generated, and in other words, the number ofgenerated flags is equal to “the number of types” multiplied by “thenumber of sizes”. Specifically, in the case of JP-A-6-337783, eightflags are generated, which is the result of the calculation “4 types”×“2sizes”=“8 flags”.

However, when the number of flags generated by each instruction isincreased, the number of instructions which use the flags must beincreased. For example, it is a common practice to decide a branchcondition of a conditional branch instruction using a combination of“which flag to use” and “whether the flag to be used has been set orcleared”. In a conditional branch instruction as described inJP-A-6-337783, 32 ways of using a flag can be designated because fivebits are ensured as a field for that. Therefore, the number ofconditional branch instructions can be determined by 32×“the number ofvariations of other-than-flag factors”. As variations of other-than-flagfactors, e.g. the presence or absence of a delay slot, and the way ofdesignating the address of a branch destination are conceivable.

As described above, “the increase in the number of flags” contributes to“the decrease in the number of instructions which generate a flag, i.e.flag-generating instructions” on one hand; however it induces “theincrease in the number of instructions which use a flag, i.e. flag-usinginstructions” on the other. Therefore, it is not always applicable thatincreasing the number of flags can reduce the number of instructions asdescribed in JP-A-06-337783. In JP-A-06-337783, where CISC (ComplicatedInstruction Set Computer) is assumed, the number of operationinstructions, which are main flag-generating instructions, is largebecause they can be used to designate a memory operand; increasing thenumber of flags thereby to cut flag-generating instructions, which arelarge in quantity, can reduce the number of instructions. In contrast, atypical RISC handles an instruction set with a fixed length of 32 bits,and has an enough instruction code space, and therefore the need forreducing the number of instructions is low. Hence, as to RISC there isnot an example that the number of flags is adjusted thereby to minimizethe number of instructions. However, for arranging a RISC processordesigned for an instruction set with a fixed length of 16 bits so as tocope with 64 bits, enough instruction code space cannot be ensured. Inaddition RISC is smaller than CISC in the number of flag-generatinginstructions. Therefore, an optimal point cannot be found by justincreasing the number of flags. It is important to arrange a systemwhich achieves a good balance between the number of instructions whichgenerate a flag and the number of instructions which use a flag.

The problem to be solved by the invention is to cut the number ofinstructions by adjusting the number of flags for an instruction sethaving a small number of flag-generating instructions, and to minimizethe code space required for defining them, thereby to arrange aprocessor tight in instruction code space like RISC designed for aninstruction set with a fixed length of 16 bits so as to cope with 64bits, which makes the first object of the invention.

In general, even when the number of flags is increased, there are fewcases in which two or more flags generated by one instruction are used;in many cases only one flag is used. On the other hand, using flagsgenerated by two or more instructions in combination can make a programmore efficient. However, it is difficult to use flags in combination.This is because when two or more flags are updated each time aninstruction is executed, a flag generated by the preceding instructionis overwritten by a subsequent instruction. Hence, the following arerequired: transferring generated flags to a register one after anotherand conducting a logical operation on the register to reflect the resulton the flag; judging, as a numeric value, a result of a logicaloperation on the register to generate a flag; or carrying out aconditional branch or conditional execution each time a flag isgenerated. These steps increase the number of instructions to beexecuted, and raise the frequency of branch, and end up worsening theefficiency and deteriorating the performance.

Particularly, in case that a certain piece of data is seen as anoperation target, the size of it never takes two types of values.Therefore, even if two flags are generated for two types of sizes, oneof them is unnecessary. It is possible that flags for two types of sizestake an identical value owing to an appropriate sign extension or zeroextension, and thus both of them can be used. However, one of them isstill unnecessary. Therefore, in case that two or more flags aredefined, it is effective to update only the flag which needs to beupdated while leaving the rest as it is, which is desired to do so, andenable an operation between the flags, rather than update all the flagsat a time. However, to actualize it, it is necessary to designate thetypes and locations of both of a flag updated by a flag-generatinginstruction and a flag used by a flag-using instruction. Hence, thelargest instruction code space is needed.

The second problem to be solved by the Invention is to take advantage ofmore than one flag defined mainly for the purpose of minimizing theinstruction code space without using a large instruction code space,thereby to make it possible to use flags generated by two or moreinstructions in combination, which makes the second object of theinvention.

Of the matters herein disclosed, the preferred ones will be outlinedbelow briefly.

The invention is based on an idea in the first aspect of the inventionthat in case that there are many flag-generating instructions, thenumber of flags generated by each instruction is increased so that adecrease of the number of flag-generating instructions exceeds anincrease of the number of flag-using instructions, whereby the reductionin the number of instructions is realized. In the first aspect, themeans of defining an instruction which generates two or more flagsaccording to the data size of an operand is adopted. In short, with adata processor of Reduced Instruction Set Computer type, an instructioncapable of executing an operation process on more than one operanddifferent in data size, which performs a process identical to anoperation process conducted on the operand of a small data size onlow-order bits of the operand with a large data size, and generatesflags capable of coping with the respective data sizes regardless of thedata size of each operand subjected to the operation process is added toan instruction set.

In the second aspect of the invention, in order to define two or moreflags, to update only the flag which needs to be updated while leavingthe rest as it is, which is desired to do so, and to enable an operationbetween the flags, a means for designating the types and locations ofboth of a flag updated by a flag-generating instruction and a flag usedby a flag-using instruction is adopted. That is, prefix instructions areadded to an instruction set, which designate: the flag to be updated bya flag generated by a subsequent instruction, of flags corresponding torespective data sizes generated by the instructions; the flag to beused, of the flags generated by the subsequent instruction that theprefix instructions modify; and a logical operation between the twodesignated flags.

Now, the effects achieved by the preferred embodiments of the invention,which are disclosed herein, are as follows in brief.

According to the first aspect of the invention, the number of kinds ofinstructions (the number of instructions) constituting an instructionset can be reduced totally. Therefore, the invention can contribute tothe reduction in the code space for instruction codes in a RISC typedata processor which is tight in its instruction code space. Forinstance, it becomes possible to arrange a processor which is tight inits instruction code space like RISC designed for an instruction setwith a fixed length of 16 bits so as to cope with 64 bits.

According to the second aspect of the invention, flags which are definedfor the principal purpose of minimization of the instruction code spaceare utilized without using a large instruction code space, therebymaking it possible to use flags generated by two or more instructions incombination.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram schematically showing an example of theconfiguration of a processor core in a data processor according to theinvention;

FIG. 2 is a block diagram schematically showing an example of anexecution unit of a processor core according to the first embodiment ofthe invention;

FIG. 3 is a diagram schematically showing an example of a flag-updateprefix instruction according to the second embodiment of the invention;

FIG. 4 is a block diagram schematically showing an example of theinstruction decode unit of a processor core according to the secondembodiment of the invention;

FIG. 5 is a block diagram schematically showing an example of theexecution unit of the processor core according to the second embodimentof the invention;

FIG. 6 is a diagram schematically showing an example of an action of theprocessor core according to the second embodiment of the invention; and

FIG. 7 is a block diagram schematically showing an example of theconfiguration of the data processor according to the invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 1. Summary of thePreferred Embodiments

The preferred embodiments of the invention herein disclosed will beoutlined first. Here, the reference characters or signs to refer to thedrawings, which are accompanied with paired round brackets, onlyexemplify what the concepts of components referred to by the charactersor signs contain.

The specific descriptions on the above-described aspects will bepresented first. According to the first aspect, flag-generatinginstructions for a RISC type 32-bit processor which handles aninstruction set with a fixed length of 16 bits consist of 17instructions having a 8-bit operand field, and 12 instructions with a4-bit operand field e.g. in the case of a SH-4A processor core describedin the document “SH-4A extended function software manual”, presented atthe following Internet URL hit in search as of Jan. 23, 2008:

<http://documentation.renesas.com/jpn/products/mpumcu/rjj09b0235_sh4asm.pdf>.Here, an instruction update using a flag is counted as a flag-generatinginstruction. Now, a floating-point instruction, which has nothing to dowith arrangement of a 64-bit processor, is not taken into account. Onthe other hand, flag-using instructions consist of 4 instructions havinga n 8-bit operand field, and one instruction with a 4-bit operand field.In addition, the number of flags is one. The smaller the number of flagsis, the larger the number of flag-generating instructions is, and thesmaller the number of flag-using instructions is. Therefore, in the caseof the SH-4A processor core, the ratio of the number of flag-generatinginstructions vs. the number of flag-using instructions is 29: 5; thenumber of flag-generating instructions is about six times larger.Further, 26 instructions of the 29 flag-generating instructions aredifferent in their ways to operate depending on the sizes of operandsand as such, simply adding a 64-bit instruction increases theflag-generating instructions by 26 instructions. As a result, the ratioof the number of flag-generating instructions vs. the number offlag-using instructions is 55:5; the number of the flag-generatinginstructions is about 11 times larger than the number of the otherinstructions.

In the case that there are many flag-generating instructions like this,the number of instructions can be reduced by increasing the number offlags generated by each instruction thereby to change the ratio of thenumber of flag-generating instructions to the number of flag-usinginstructions. The possible ways of increasing the flags include:defining flags according to (1) the flag type, (2) the operand size or(3) both of them.

First, (1) the way of defining flags according to the flag type will bedescribed. The types of flags for the SH-4A processor core include e.g.Signed Large/Signed Small, Unsigned Large/Unsigned Small, Zero,Overflow, Carry, and Shift-out Bit. Each flag is constructed of one bit,and therefore what it indicates changes depending on what instructionhas put the flag. In case that different operations put different typesof flags up, the number of instructions cannot be decreased byincreasing the types of the flags. Therefore, when notice is taken ofthe case that only the flags generated in the same operation aredifferent, a comparing instruction becomes a candidate. The number ofcomparing instructions can be shrunk from 18 to 8 by setting the threeindividual flags of Signed Large/Signed Small, Unsigned Large/UnsignedSmall and Zero. As to other instructions generate the flags of Zero,Overflow, Carry, Shift-out Bit, etc., which are different in operations,the effect of reducing the number of instructions cannot be attainedeven when flags are classified according to flag types. On the otherhand, the number of flag-using instructions is tripled according to thenumber of flag types, and five instructions form 15 instructions. As aresult, the number of flag-related instructions is reduced from 60 by10, and increased by 10, and therefore it remains 60.

Second, (2) the way of defining flags according to the operand size willbe described. When flags are provided according to operand sizes of 32and 64 bits, of 29 instructions differing in actions depending onoperand sizes, 15 instructions which are the same in actions dependingon the low-order 32 bits can be made instructions common to 32 and 64bits. However, the size of flags is doubled, and therefore the number offlag-using instructions is changed from 5 to 10. As a result, the numberof flag-related instructions is decreased from 60 by 15, and increasedby 5, and therefore it is reduced to 50.

Further, (3) the way of defining flags according to both the flag typeand operand size will be described. First, the number of comparinginstructions can be reduced from 18 to 8 by using the three types offlags. Further, eight instructions can be decreased to four ones bydefining flags according to the sizes. Further, of flag-generatinginstructions other than comparing instructions, the instructions whichare the same in action corresponding to the low-order 32 bits can bereduced by six instructions. However, the number of flag-usinginstructions is sextupled according to the number of flag types, andtherefore it is increased from 5 to 30. As a result, the number offlag-related instructions is decreased from 60 by 20 and increased by25, and therefore it ends up being increased to 65.

From optimization of the number of flags in terms of minimization of thenumber of instructions as described above, it has become evident (2) theway of defining flags according to the operand size is the best option.

The instruction code space consumed by an instruction largely changesdepending on the number of bits which the instruction uses for anoperand field. In the condition that N bits are used, a spacerepresenting one 2^((16−N))-th the whole instruction code space isconsumed. For instance, a space of 1/256 the whole instruction codespace is consumed with eight bits for an operand field, and a space of1/4096 is consumed with four bits. On this account, it is important toreduce the number of instructions with eight bits for an operand field.

Hence, the above estimation was made on only instructions having an8-bit operand field, which are also referred to as “8-bit operand fieldinstructions” simply. The results are as follows. Flag-relatedinstructions having an 8-bit operand field for a 32-bit processorconsist of a total of 21 instructions, i.e. 17 flag-generatinginstructions and four conditional branch instructions as flag-usinginstructions, which add up to 21 instructions. Of the 21 instructions,15 flag-generating instructions are different in their actions dependingon the operand sizes. Therefore, when a 64-bit instruction is addedsimply, the number of flag-generating instructions is increased by 15 to32, and the number of instructions is made 36 in total.

First, with (1) the way of defining flags according to the flag type,when three types of flags are defined, the number of comparinginstructions can be shrunk from 17 to 6, whereas the number ofconditional branch instructions is increased from 4 to 12. That is, thenumber of flag-related instructions is decreased from 36 by 8, and thenincreased by 8, and therefore it remains 36.

With (2) the way of defining flags according the operand size, of 15instructions which are different in actions according to operand sizes,10 instructions which are the same in action corresponding to thelow-order 32 bits can be made instructions common to 32 and 64 bits. Onthe other hand, the number of flags is doubled, and therefore the numberof conditional branch instructions is changed from four to eight. As aresult, the number of flag-related instructions is decreased from 36 by10, and then increased by 4, and therefore it ends up being reduced to30.

Further, consideration is made for (3) the way of defining flagsaccording to both the flag type and operand size here. First, the numberof comparing instructions can be shrunk from 14 to 6 by defining threetypes of flags. Further, the number of comparing instructions can bedecreased from six to three by defining flags according to the size.Also, of flag-generating instructions other than comparing instructions,the instructions which are the same in action corresponding to thelow-order 32 bits can be reduced by three instructions. On the otherhand, the number of flag-using instructions is sextupled according tothe number of flag types, and therefore it is increased from 4 to 24. Asa result, the number of flag-related instructions is decreased from 36by 14, and then increased by 20, and therefore it ends up beingincreased to 42.

As described above, even in the case where the targets are limited toonly 8-bit operand field instructions having a large influence onconsumption of the instruction code space, it is the best evident (2)the way of defining flags according to the operand size is the bestoption. Now, it is noted that the way stated marked with (3), which hasbeen considered to be the best as a means for minimizing the code sizeof an instruction in case that the three ways are applied to CISC as inJP-A-06-337783, is regarded as being the worst one to RISCs.

The first object of the invention can be achieved by defining flagsaccording to the operand size, provided that the first object is to cutthe number of instructions by adjusting the number of flags for aninstruction set having a small number of flag-generating instructions,and to minimize the code space required for defining them, thereby toarrange a processor tight in instruction code space like RISC designedfor an instruction set with a fixed length of 16 bits so as to cope with64 bits. Specifically, the first object can be achieved by providing aflag for each of operand sizes of 32 and 64 bits, integratinginstructions which are the same in action corresponding to the low-order32 bits by means of an instruction with 32-bit and 64-bit operands, andincreasing the number of flag-using instructions, such as conditionalbranches, according to increase in the number of flags. Thus, the kindsof instructions constituting an instruction set, i.e. the number ofinstructions, can be reduced totally.

From the second aspect of the invention, as stated in the descriptionabout the problems to be solved by the invention, in order to define twoor more flags, update the flag which needs to be updated while leavingthe rest as it is, and enable an operation between the flags, it isnecessary to designate the types and locations of both of a flag updatedby a flag-generating instruction and a flag used by a flag-usinginstruction, and therefore the largest instruction code space is needed.

To solve the problem, it is only necessary to define a prefixinstruction, which is an instruction modifying a subsequent instruction.Implementation of a prefix instruction is similar to implementation of avariable-length instruction set. A processor which uses a prefixinstruction has been used in the past as described in and after the page87 of the document “AMD64 Architecture Programmer's Manual Volume 1:Application Programming, Revision 3.11”, presented at the followingInternet URL hit in search as of Jan. 23, 2008:

<http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24592.pdf>.It is possible for a person skilled in the art to implement a prefixinstruction. What is important is what prefix instruction is defined. Inthis invention, a flag-update prefix instruction includes: designating aflag to be updated; designating, of flags generated by a subsequentinstruction, a flag to be used; and designating a logical operationbetween the flags thus designated. Assuming two types of flags and eighttypes of operations, the flags and logical operations can be designatedwith a 5-bit operand field; a large instruction code space is notneeded. As a logical operation can be designated, a logical operationbetween flags can be executed with an instruction set, which can stopupdate of the flag desired to be left, and whose instructions' numberagrees with that when the logical operation is performed by otherinstructions. Thus, the following are made possible: to take advantageof flags defined mainly for the purpose of minimizing the instructioncode space without using a large instruction code space; and using, incombination, the flags generated by two or more instructions.

In consideration of the aspects, the preferred embodiments will bedescribed here.

[1] The data processor of Reduced Instruction Set Computer type uses aninstruction set including a first instruction capable of executing anoperation process on operand of more than one data size, which performsa process identical to an operation process conducted on the operand ofa small data size on low-order bits of the operand with a large datasize, and generates flags (newU and newT) capable of coping withrespective data sizes regardless of the data size of each operandsubjected to the operation process. Thus, the kinds of instructionsconstituting an instruction set, i.e. the number of instructions, can bereduced totally. Therefore, this can contribute to reduction of theinstruction code space of a data processor of RISC type which is tightin instruction code space. For example, it becomes possible to arrange aprocessor which is tight in instruction code space like RISC designedfor an instruction set with a fixed length of 16 bits so as to cope with64 bits.

[2] In regard to the data processor as stated in [1], the instructionset further includes a second instruction which selects and uses e.g. aflag generated by the first instruction.

[3] In regard to the data processor as stated in [1], the instructionset further includes, for example, a prefix instruction whichdesignates, of the flags capable of coping with the respective datasizes generated by the first instruction, the flag to be updated by aflag generated by a subsequent instruction that the prefix instructionmodifies. Thus, it becomes possible to update, of defined flags, only arequired flag.

[4] In regard to the data processor as stated in [1], the instructionset has, for example, a prefix instruction which designates, of theflags capable of coping with the respective data sizes generated by thefirst instruction, the flag to be updated by a flag generated by asubsequent instruction, designates, of flags generated by the subsequentinstruction that the prefix instruction modifies, the flag to be used,and designates a logical operation between the two designated flags.Thus, the following are made possible: to update, of defined flags, onlya required flag leaving the flag desired to be left; and to perform anoperation between the flags. Hence, flags which are defined for theprincipal purpose of minimization of the instruction code space areutilized without using a large instruction code space, thereby making itpossible to use flags generated by two or more instructions incombination.

[5] In regard to the data processor as stated in [1], the data sizes aree.g. 32 and 64 bits.

[6] In regard to the data processor as stated in [2], the flags, forexample, are Signed Large and Signed Small, Unsigned Large and UnsignedSmall, Zero, Overflow, and Carry and Shift-out bit for each data size.

[7] Another data processor of Reduced Instruction Set Computer type has:an instruction-executing unit (EXU); and an instruction set having afirst instruction for executing a process involving flag generation, anda second instruction for executing a process involving use of a flag.The instruction-executing unit has an operation circuit (ALU, SFT) whichperforms a process according to a result of decode of an instruction, aflag latch circuit (U, T), and a flag select circuit (FMUX). Theoperation circuit is capable of executing an operation process on morethan one operand different in data size according to a result of decodeof the first instruction, and performs a process identical to anoperation process conducted on the operand of a small data size onlow-order bits of the operand with a large data size, and generatesflags capable of coping with the respective data sizes regardless of thedata size of each operand subjected to the operation process. The flaglatch circuit latches a flag generated by the operation circuitaccording to a result of decode of the first instruction. The flagselect circuit selects the flag latched by the flag latch circuit,according to a result of decode of the second instruction.

[8] In regard to the data processor as stated in [7], the operationcircuit, for example, generates flags of Signed Large and Signed Small,Unsigned Large and Unsigned Small, Zero, Overflow, Carry and Shift-outbit for each data size, and one of the flags thus generated is selectedby the first instruction, and latched by the flag latch circuit for eachoperand size.

[9] In regard to the data processor as stated in [8], the data sizes aree.g. 32 and 64 bits.

[10] Another data processor includes an instruction set having anoperation instruction capable of executing an operation process therebyto generate flags, and a prefix instruction which designates, of theflags generated by the operation instruction, the flag to be updated bya flag generated by a subsequent instruction, and which modifies thesubsequent instruction.

[11] Still another data processor includes an instruction set having anoperation instruction capable of executing an operation process therebyto generate flags, and a prefix instruction which designates, of flagsgenerated by the operation instruction, the flag to be updated by a flaggenerated by a subsequent instruction, designates, of flags generated bythe subsequent instruction that the prefix instruction modifies, theflag to be used, and designates a logical operation between the twodesignated flags.

2. Further Detailed Description of the Preferred Embodiments

Next, with reference to the drawings, the preferred embodiments will bedescribed below further in detail. It is noted that as to all thedrawings to which reference is made in describing the preferredembodiments, the members having functions identical to each other areidentified by the same reference numeral, and the repeated descriptionthereof is avoided herein.

FIRST EMBODIMENT

FIG. 7 shows an example of a data processor DPU according to theinvention. The data processor DPU has a processor core CPU, such as acentral processing unit, and a non-volatile memory ROM connected withthe processor core through an internal bus, a volatile memory RAM, anI/O interface circuit IOC, an external bus interface circuit EBIF andothers, which are placed around the processor core. The data processorDPU can be formed on a semiconductor substrate made of e.g.single-crystal silicon by e.g. a complementary MOS IC manufacturingtechnique. The non-volatile memory ROM is used as a storage area forstoring a program that the processor core CPU runs and others. Thevolatile memory RAM is used as a work area for the processor core CPU,and for other purpose.

FIG. 1 schematically shows an example of the configuration of blocks ofthe processor core CPU. For example, the processor core CPU includes: aninstruction cache IC; an instruction fetch unit IFU; an instructiondecode unit IDU; an execution unit EXU; a load/store unit LSU; a datacache DC; and a bus interface unit BIU.

The instruction fetch unit IFU outputs an instruction address IA to theinstruction cache IC. Then, the instruction cache IC fetches aninstruction from the address designated by the instruction address IA,and returns the fetched instruction FI to the instruction fetch unitIFU. In case of occurrence of a cache miss, the instruction cache ICoutputs an address where the miss has occurred as an externalinstruction address EIA to the bus interface unit BIU, and receives anexternal fetch instruction EI and then returns the instruction FI to theinstruction fetch unit IFU.

The instruction decode unit IDU receives an instruction OP from theinstruction fetch unit IFU, and outputs a branch control signal BRC.Also, the instruction decode unit IDU decodes the instruction OP, andoutputs an execution control information EXC and load/store controlinformation LSC to the execution unit EXU and load/store unit LSUrespectively. In parallel with this, the instruction decode unit IDUaccesses a register file RF, and supplies operands EXA and EXB forexecution to the execution unit EXU, and supplies address operands LSAand LSB for load and store, and store data SD to the load/store unitLSU. Further, the instruction decode unit IDU receives an executionresult EXO from the execution unit EXU, and load data LD from theload/store unit LSU, and stores them in the register file RF.

The execution unit EXU receives the execution control information EXC,and operands EXA and EXB for execution from the instruction decode unitIDU, and executes an operation according to the execution controlinformation EXC, and thereafter returns the execution result EXO to theinstruction decode unit IDU.

The load/store unit LSU receives the load/store control information LSC,address operands LSA and LSB for load and store and store data SD fromthe instruction decode unit IDU, and executes load/store according tothe load/store control information LSC, and thereafter returns load dataLD to the instruction decode unit IDU. In loading/storing, theload/store unit LSU outputs a data address DA to the data cache DC.Further, the load/store unit LSU outputs data cache store data DCSD instoring. The data cache DC returns data cache load data DCLD to theload/store unit LSU in loading, whereas it stores the data cache storedata DCSD therein in storing. In case of occurrence of a cache miss, thedata cache DC outputs an address where the miss has occurred as anexternal data address EDA to the bus interface unit BIU. The data cacheDC receives external load data ELD, and then returns data cache loaddata DCLD to the load/store unit LSU. In copy back of data in responseto the occurrence of a cache miss, and storing, in place on the outside,data which has not been cached, the data cache DC outputs the data ofquestion as external store data ESD, and in parallel outputs an addressof these data as an external data address EDA.

On receipt of an external instruction address EIA/external data addressEDA from the instruction cache IC/data cache DC, the bus interface unitBIU outputs an external address EA to the outside of the processor coreCPU, and requests data. Then, the bus interface unit BIU receivesexternal data ED, and outputs the data as the external fetch instructionEI/external load data ELD. Also, on receipt of the external data addressEDA and the external store data ESD from the data cache DC, the businterface unit BIU outputs them as the external address EA and theexternal data ED to the outside of the processor core CPU, and issues astore request.

FIG. 2 schematically shows an example of the execution unit EXU of theprocessor according to the first embodiment of the invention. Theexecution unit EXU includes: an arithmetic and logical operation unitALU; a shifter SFT; a 32-bit flag multiplexer FM32; a 64-bit flagmultiplexer FM64; a 32-bit shift-out multiplexer M32; a 64-bit shift-outbit multiplexer M64; an output multiplexer OMUX; a 32-bit operation flagT; a 64-bit operation flag U; and a flag multiplexer FMUX. Although thisis not shown in the drawing, the execution control information EXC fromthe instruction decode unit IDU is input to the constituent parts andused to control them.

On receipt of the operands EXA and EXB for execution from theinstruction decode unit IDU, the arithmetic and logical operation unitALU executes various arithmetic logical operations according to theexecution control information EXC. Thereafter, the arithmetic andlogical operation unit ALU outputs an execution result ALO, a group of32-bit flags (Signed Large GT32, Unsigned Large GU32, Zero Z32, OverflowV32 and Carry C32), and a group of 64-bit flags (Signed Large GT64,Unsigned Large GU64, Zero Z64, Overflow V64 and Carry C64).

On receipt of the operands EXA and EXB for execution from theinstruction decode unit IDU, the shifter SFT executes various shiftoperations according to the execution control information EXC.Thereafter, the shifter SFT outputs an execution result SFO, a 32-bitleft-shift-out bit SL32, a 64-bit left-shift-out bit SL64, and aright-shift-out bit SR. Then, the 32-bit shift-out bit multiplexer M32selects the 32-bit left-shift-out bit SL32 or right-shift-out bit SRaccording to the direction of the shift operation, and outputs theselected left- or right-shift-out bit as a 32-bit shift-out flag SF32,which is one of the group of 32-bit flags. Also, the 64-bit shift-outbit multiplexer M64 selects the 64-bit left-shift-out bit SL64 orright-shift-out bit SR according to the direction of the shiftoperation, and outputs the selected left- or right-shift-out bit as a64-bit shift-out flag SF64, which is one of the group of 64-bit flags.

The output multiplexer OMUX selects one of the execution result ALO andthe execution result SFO according to the execution control informationEXC, and outputs the selected one as the execution result EXO.

The 32-bit flag multiplexer FM32 selects a flag among the group of32-bit flags according to the kind of an instruction to generate a new32-bit flag newT, and inputs the flag to the 32-bit flag T. Likewise,the 64-bit flag multiplexer FM64 selects a flag among the group of64-bit flags according to the kind of an instruction to generate a new64-bit flag newU, and inputs the flag to the 64-bit flag U. The 32-bitflag T and 64-bit flag U latch the inputs, and output them to the flagmultiplexer FMUX. The flag multiplexer FMUX selects one of the 32-bitflag T and 64-bit flag U according to an instruction which is to use it,and outputs the selected one as a flag output FO. The flag multiplexerFMUX uses a value after latch to select the flag which a subsequentinstruction is to use. The flag multiplexer FMUX can receive controlinformation for the subsequent instruction by use of a value beforelatch as the execution control information EXC from the instructiondecode unit IDU, which is not shown in the drawing.

According to the first embodiment, the number of kinds of instructions(i.e. the number of instructions) constituting an instruction set can bereduced totally. Therefore, it can contribute to the reduction in thecode space for instruction codes in a RISC type data processor which istight in its instruction code space. Further, it becomes possible toarrange a processor which is tight in its instruction code space likeRISC designed for an instruction set with a fixed length of 16 bits soas to cope with 64 bits.

SECOND EMBODIMENT

FIG. 3 schematically shows an example of a flag-update prefixinstruction according to the second embodiment of the invention. Theflag-update prefix instruction designates the flag to be updated,designates, of flags generated by a subsequent instruction, the flag tobe used, and designates a logical operation between two designatedflags. Assuming two types of flags, i.e. the 32-bit flag T and 64-bitflag U, one bit is used to designate the flag to be updated, and anotherone bit is used to designate, of flags generated by a subsequentinstruction, the flag to be used. Further, assuming six types ofoperations, three bits are used to designate a logical operation betweentwo designated flags. Hence, a flag-update prefix instruction candesignate the flags and the logical operation with five bits of operandfield, which does not require a large instruction code space.

As shown in FIG. 3, when the flag-update prefix instruction is definedin the form of an instruction set with a fixed length of 16 bits, anoperation type designating field OPT of 11 bits is used to indicate aflag-update prefix instruction; a source-and-destination-designatingfield SD of two bits is used to designate the flag to be updated anddesignate, of flags generated by a subsequent instruction, the flag tobe used; and a logical operation-designating field TYP of three bits isused to designate a logical operation between two designated flags.There are six types of logical operations, i.e. and (AND), or (OR),invert-and (ANDN), invert-or (ORN), exclusive-or (XOR), and new-flag(NEW) operations, which are assigned 000 to 101 in TYP fieldrespectively. Source and destination flags are added to the operationtype, thereby forming a mnemonic. As to SD field, the upper bitdesignates a source, and the lower bit designates a destination.Specifically, zero (0) shows to designate the 32-bit flag T, and one (1)shows to designate the 64-bit flag U. In the actions' section, “newT”represents a 32-bit flag generated by a subsequent instruction, and“newU” represents a 64-bit flag generated by a subsequent instruction.Further, &=, |=, {circle around ( )}=, =, and ˜ are operators which arethe same in function as those in C language. Specifically, “&=” means totake the AND of the right-hand side value and left-hand side value, andthen replace the variable of the left-hand side with the ANDed value,“|=” means to take the OR of the right-hand side value and left-handside value, and then replace the variable of the left-hand side with theORed value, “{circle around ( )}=” means to take the XOR of theright-hand side value and left-hand side value, and then replace thevariable of the left-hand side with the XORed value, “=” means toreplace the variable of the left-hand side with the value of theright-hand side, and “˜” means to logically invert the right side value.

For example, in the case where SD=00 and TYP=000, the applicableinstruction is a flag-update prefix instruction characterized in thetype of the logical operation is the AND, the flag to be updated(destination flag) is a 32-bit flag T, the flag to be used (sourceflag), which is one of flags generated by a subsequent instruction, isalso a 32-bit flag T, the mnemonic is ANDTT, and the action includes, asdesignated by “T &=newT; U: unchanged”, taking the AND of the 32-bitflag T and the 32-bit flag T, which is one of flags generated by asubsequent instruction, and storing it as the 32-bit flag T withoutupdating the 64-bit flag U. And then, the action of the subsequentinstruction is replaced with the action designated by the flag-updateprefix instruction although the 32-bit flag T and 64-bit flag U would beupdated with the generated flag if there was no prefix instruction.

The difference between the first and second embodiments in structure canbe seen in the instruction decode unit IDU and the execution unit EXU.Therefore, the typical configuration of blocks of the processor coreaccording to the second embodiment is shown in FIG. 1, as in the case ofthe first embodiment.

FIG. 4 schematically shows an example of the instruction decode unit IDUof the processor according to the second embodiment. The processor shownas an example in the drawing is a scalar processor which issues oneinstruction in each cycle. A processor which uses a prefix instructionhas been used in the past as described in the document “AMD64Architecture Programmer's Manual Volume 1: Application Programming,Revision 3.11”. Therefore, it is possible for a person skilled in theart to apply the prefix decode and issue techniques according to theinvention to other issue modes such as superscalar and out-of-ordertechniques. It is assumed in this embodiment that only the flag-updateprefix instruction is a prefix instruction. However, it is also possiblefor a person skilled in the art to extend the processor so that it canhandle another prefix instruction additionally.

The instruction decode unit IDU includes a main decoder DEC and a prefixdecoder PF-DEC. The main decoder DEC decodes an instruction OP suppliedfrom the instruction fetch unit IFU, and outputs an execution controlinformation op-exc to the execution unit EXU as a part of the executioncontrol information EXC, update control information op-wrt for a 32-bitflag and update control information op-wru for the 64-bit flag U to theprefix decoder PF-DEC, load/store control information LSC to theload/store unit LSU, and register-file control information RFC to theregister file RF. Incidentally, of the register-file control informationRFC, write information is supplied in keeping with the timing that anissued instruction reaches a register write stage.

Based on the register-file control information RFC, the register file RFsupplies operands EXA and EXB for execution to the execution unit EXU,and address operands LSA and LSB for load and store and store data SD tothe load/store unit LSU. Further, the instruction decode unit IDUreceives an execution result EXO from the execution unit EXU, andaccepts load data LD from the load/store unit LSU, and stores them inthe register file RF.

The prefix decoder PF-DEC decodes the content of the operation typedesignating field OPT of the instruction OP. The prefix decoder PF-DECsets a valid flag v if the instruction OP is a flag-update prefix, orotherwise clears it. The prefix decoder PF-DEC latches two bits ofsource-and-destination field SD as prefix source-flag information pfsrcand prefix destination-flag information pfdst respectively. Further, theprefix decoder PF-DEC latches the content of thelogical-operation-designating field TYP as prefixlogical-operation-designating information pftyp. If the instruction OPis a flag-update prefix instruction, it is also supplied to the maindecoder DEC. At that time, the main decoder DEC regards the flag-updateprefix as a no-operation code, and outputs control information, by whichthe execution unit EXU and load/store unit LSU do nothing.

In the cycle subsequent to a cycle in which the instruction OP is aflag-update prefix instruction, the main decoder DEC decodes thesubsequent instruction, and outputs the various control information asdescribed above. On the other hand, the prefix decoder PF-DEC goes aheadwith the process steps using the information latched in the precedingcycle. As the instruction OP was a flag-update prefix instruction in thepreceding cycle, the valid flag v remains set in this cycle. Therefore,the following are output as logical-operation-designating informationtyp, 32-bit flag source information srt, 64-bit flag source informationsru, 32-bit flag update control information wrt, and 64-bit flag updatecontrol information wru respectively: prefixlogical-operation-designating information pftyp; prefixflag-source-designating information pfsrc; prefix flag-sourceinformation pfsrc, which is identical to the preceding information; andequivalence of prefix destination-flag information pfdst and zero (0);and equivalence of prefix destination-flag information pfdst and one(1). As a result, the 32-bit flag update control information op-wrt and64-bit flag update control information op-wru from the main decoder areoverwritten as control information for flag generation, and theninformation of the flag-update prefix instruction is output.

In contrast, in the cycle subsequent to a cycle in which the instructionOP is not a flag-update prefix instruction, the valid flag v has notbeen set. Therefore, output as the logical-operation-designatinginformation typ, 32-bit flag source information srt, 64-bit flag sourceinformation sru, 32-bit flag update control information wrt, and 64-bitflag update control information wru are 101, 0, 1, the 32-bit flagupdate control information op-wrt, and the 64-bit flag update controlinformation op-wru respectively. As a result, the output of the maindecoder DEC is put outside as an output of the instruction decode unitIDU. Now, it is noted that the default action of the instruction isspecified by outputting 101, 0 and 1 as thelogical-operation-designating information typ, 32-bit flag sourceinformation srt, and 64-bit flag source information sru, respectivelywithout any corresponding outputs from the main decoder DEC.

The logical-operation-designating information typ, 32-bit flag sourceinformation srt, 64-bit flag source information sru, 32-bit flag updatecontrol information wrt, and 64-bit flag update control information wru,and the execution control information op-exc generated by the maindecoder DEC are output to the execution unit EXU as the executioncontrol information EXC.

FIG. 5 schematically shows an example of the execution unit EXU of theprocessor according to the second embodiment. The like parts, which arecommon between the execution units EXU according to the first and secondembodiments, shall have the same functions as those of the executionunit according to the first embodiment shown in FIG. 2. The parts addedaccording to the second embodiment are a 32-bit flag source multiplexerS32, a 64-bit flag source multiplexer S64, a 32-bit flag logicaloperation unit FL32, and a 64-bit flag logical operation unit FL64.

The 32-bit flag source multiplexer S32 selects one of the new 32-bitflag newT and new 64-bit flag newU according to the 32-bit flag sourceinformation srt from the instruction decode unit IDU, and supplies theselected one to the 32-bit flag logical operation unit FL32. The 32-bitflag logical operation unit FL32 performs a logical operation with the32-bit flag T and the one selected from among the new 32-bit flag newTand new 64-bit flag newU, according to the logical-operation-designatinginformation typ. The result is made a new value latched by the 32-bitflag T. Likewise, the 64-bit flag source multiplexer S64 selects one ofthe new 32-bit flag newT and new 64-bit flag newU according to the64-bit flag source information sru from the instruction decode unit IDU,and supplies the selected one to the 64-bit flag logical operation unitFL64. The 64-bit flag logical operation unit FL64 performs a logicaloperation with the 64-bit flag U and the one selected from among the new32-bit flag newT and new 64-bit flag newU, according to thelogical-operation-designating information typ. The result is made a newvalue latched by the 64-bit flag U.

As described above, the instruction decode unit IDU and execution unitEXU according to the second embodiment make possible using a flag-updateprefix instruction which does not need a large instruction code space:to stop update of the flag desired to be unchanged; and to conduct alogical operation between flags generated by two or more instructions.

Next, the effect of the flag-update prefix instruction will be describedbased on a concrete example. FIG. 6 schematically shows an example of anaction of the processor according to the second embodiment. In the Cprogram of FIG. 6, if a 64-bit pointer p is not NULL pointer and a32-bit variable i is larger than 10, then the instruction writtenbetween parentheses is executed. NULL pointer designates nothing, andthe value is zero (0).

If this C program is written with an assembler including a flag-updateprefix instruction, it can be written with four instructions as shown inFIG. 6. In the first step, the value of the 64-bit pointer p is comparedwith NULL pointer's value 0 in 64-bit size according to the instructionCMP/EQ p, 0, and the result of the comparison is stored in the 64-bitflag U. If the 64-bit pointer p is NULL pointer, the 64-bit flag U isput up, i.e. U=(p==NULL). At that time, the result of comparison of thevalue of the 64-bit pointer p with NULL pointer's value 0 in thelow-order 32 bits is stored in the 32-bit flag T, which is not used inthis program. In the second step, the flag-update prefix instructionORNTU is decoded. In the third step, if the 32-bit variable i is largerthan 10, then the new 32-bit flag newT is set, according to theinstruction CMP/GT i,10. Further, U|=˜newT according to the flag-updateprefix instruction ORNTU, and therefore, U=(p==NULL)|˜(i>10). In thistime, the 32-bit flag T is unchanged. As a result, the reversal value ofthe conditional expression of IF statement of the C program is placed inthe 64-bit flag U. In the fourth step, if U=1, i.e. the conditionalexpression is not met, the processor jumps to the line just after IFstatement, according to the instruction BT.D_after_if_close, andtherefore IF statement is not executed.

As described above, more than one comparison result can be piecedtogether by using a flag-update prefix instruction, and thereforejudgment of a condition is completed by one conditional branch. In casethat no flag-update prefix instruction is used, a conditional branchneeds to be conducted each time of judgment of a condition, which ishard to speed up. Alternatively, the following procedure is carried outin case that a generated flag is transferred to a general-purposeregister and then a logical operation is performed: a flag transferinstruction MOVU R0 is executed instead of the flag-update prefixinstruction of the second step thereby to transfer the generated U flagto the general-purpose register R1; and a flag transfer instruction MOVTR0 is executed thereby to transfer the generated T flag to thegeneral-purpose register R1 before the conditional branch of the fourthstep; logical reversal is performed by NOT R0; high-order bits arecleared by AND #1,R0; and (p==NULL)|˜(i>10) is generated by OR R0, R1.Further, (p==NULL)|˜(i>10) is stored in the 32-bit flag T by SHLR R1.Thus, the number of instructions is increased by four, i.e. doubled,resulting in the deterioration in performance. The flag-update prefixinstruction can accelerate complicated condition judgments.

Although invention made by the inventor has been concretely describedabove based on the embodiments, it is not limited to the embodiments. Itis needless to say that various changes and modifications may be madewithout departing from the subject matter hereof. For example, theflag-update prefix instructions, as typified by ORNTU, have the functionof designating the flag to be updated by a flag generated by thesubsequent instruction, the function of designating the flag to be usedof flags generated by the subsequent instruction, and the function ofdesignating a logical operation between two designated flags. However,the invention is not limited to such example. The flag-update prefixinstruction may be an instruction having only the function ofdesignating, of flags corresponding to the data sizes generatedpreviously, the flag to be updated by a flag generated by the subsequentinstruction.

1-11. (canceled)
 12. A data processor of Reduced Instruction SetComputer type, comprising: an instruction execution unit configured toexecute instructions of an instruction set, wherein the instruction setincludes a first instruction which causes execution of a first operationprocess on a small data size operand and a second operation process on alarge data size operand, wherein the instruction execution unit isconfigured to execute the first operation process on a small data sizeoperand and to generate flags corresponding to the small data sizeoperand and the large data size operand, wherein the instructionexecution unit is configured to execute the second operation process onlow-order bits of the large data size operand and to generate flagscorresponding to the small data size operand and the large data sizeoperand, wherein the first and second operation processes are identicalprocesses, wherein the instruction set has a prefix instruction whichmodifies a subsequent instruction, and wherein the modification to thesubsequent instruction includes designating a flag from among said flagscorresponding to the small data size operand and the large data sizeoperand to be updated by the subsequent instruction.
 13. A dataprocessor of Reduced Instruction Set Computer type, comprising: aninstruction execution unit configured to execute instructions of aninstruction set, wherein the instruction set includes a firstinstruction which causes execution of a first operation process on asmall data size operand and a second operation process on a large datasize operand, wherein the instruction execution unit is configured toexecute the first operation process on a small data size operand and togenerate flags corresponding to the small data size operand and thelarge data size operand, wherein the instruction execution unit isconfigured to execute the second operation process of the identicaloperation as the first operation process on low-order bits of the largedata size operand and to generate flags corresponding to the small datasize operand and the large data size operand, and wherein theinstruction set has a prefix instruction which designates a flag fromamong the flags associated with the respective data sizes and which isupdated by a subsequent instruction, and which further designates a flagto use from among flags generated by the subsequent instruction and alogical operation between the two designated flags.
 14. The dataprocessor according to claim 12, wherein the small data size is 32 bitsand the large data size is 64 bits.
 15. The data processor according toclaim 12, wherein the instruction set has a second instruction whichselects and uses the flags generated by the first instruction.
 16. Thedata processor according to claim 13, wherein the instruction set has asecond instruction which selects and uses the flags generated by thefirst instruction.
 17. The data processor according to claim 13, whereinthe small data size is 32 bits and the large data size is 64 bits. 18.The data processor according to claim 15, wherein the flag correspondingto the small data size operand is one of Signed Large flag, Signed Smallflag, Unsigned Large flag, Unsigned Small flag, Zero flag, Overflowflag, Carry flag and Shift-out bit flag, and wherein the flagcorresponding to the large data size operand is one of Signed Largeflag, Signed Small flag, Unsigned Large flag, Unsigned Small flag, Zeroflag, Overflow flag, Carry flag and Shift-out bit flag.
 19. The dataprocessor according to claim 16, wherein the flag corresponding to thesmall data size operand is one of Signed Large flag, Signed Small flag,Unsigned Large flag, Unsigned Small flag, Zero flag, Overflow flag,Carry flag and Shift-out bit flag, and wherein the flag corresponding tothe large data size operand is one of Signed Large flag, Signed Smallflag, Unsigned Large flag, Unsigned Small flag, Zero flag, Overflowflag, Carry flag and Shift-out bit flag.